package cn.hxh.servlet;

import cn.hxh.util.CheckUtils;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * @Author: HongXiaoHan
 * @Description
 * @Date: 2020/11/6 12:20
 */

@WebServlet("/check")
public class CheckImgServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CheckUtils checkUtils = new CheckUtils();
        BufferedImage image = checkUtils.getImage();
        checkUtils.outPut(image,resp.getOutputStream());
        System.out.println(checkUtils.getText());
    }
}
